<?php
  
     /*
      * Following code will create a new row
      * All details are read from HTTP Post Request
      */
      
     // array for JSON response
     $response = array();
      
     // check for required fields
     if (isset($_GET['place_id']) && isset($_GET['user_id_zing'])) {
      
         $user_id_zing = $_GET['user_id_zing'];
		 $place_id = $_GET['place_id'];
      
         // include db connect class
         require_once __DIR__ . '/db_connect.php';
      
         // connecting to db
         $db = new DB_CONNECT();
      
         // mysql inserting a new row
         $result = mysql_query("SELECT * FROM `rating`
								WHERE `user_id_zing` = '$user_id_zing'
									AND `place_id` = '$place_id'") or die(mysql_error());;
      
         if (mysql_num_rows($result) > 0) {
			// looping through all results
			// rating node
			$response["rating"] = array();
		 
			while ($row = mysql_fetch_array($result)) {
				// temp user array
				$rating = array();    
			
			$rating["user_id_zing"] = $row['user_id_zing'];
			$rating["place_id"] = $row['place_id'];
		 
				// push single rating into final response array
				array_push($response["rating"], $rating);
			}
			// success
			$response["success"] = 1;
		 
			// echoing JSON response
			echo json_encode($response["rating"]);
		} else {
			// no report found
			$response["success"] = 0;
			$response["message"] = "No report found";
		 
			// echo no users JSON
			echo json_encode($response);
		}
    } else {
         // required field is missing
         $response["success"] = 0;
         $response["message"] = "Required field(s) is missing";
      
         // echoing JSON response
         echo json_encode($response);
    }
?>